#!/bin/sh

if [ $1 != "get" ]; then
    exit 1
fi

read inputLine

if [ "$inputLine" = "registry2.example.com" ]; then
    echo Fake credentials not found on credentials store \'$inputLine\' 0>&2
    exit 1
fi

if [ "$inputLine" = "registry.example.com" ]; then
    echo '{' \
        '  "ServerURL": "url",' \
        '  "Username": "username",' \
        '  "Secret": "secret"' \
        '}'
    exit 0
fi
if [ "$inputLine" = "registrytoken.example.com" ]; then
    echo '{' \
        '  "ServerURL": "url",' \
        '  "Username": "<token>",' \
        '  "Secret": "secret"' \
        '}'
    exit 0
fi
if [ "$inputLine" = "registrynoserverurl.example.com" ]; then
    echo '{' \
        '  "Username": "username",' \
        '  "Secret": "secret"' \
        '}'
    exit 0
fi
if [ "$inputLine" = "registrynoserverurltoken.example.com" ]; then
    echo '{' \
        '  "Username": "<token>",' \
        '  "Secret": "secret"' \
        '}'
    exit 0
fi

exit 1
